"""
@author: 景云鹏
@email: 310491287@qq.com
@date: 2022/6/13
"""
from typing import List


class Solution:
    def canJump(self, nums: List[int]) -> bool:
        if len(nums) == 1:
            return True
        i = 0
        while True:
            next_step = i
            max_step = i
            if nums[i] == 0:
                return False
            for j in range(i + 1, i + nums[i] + 1):
                if j + nums[j] >= len(nums) - 1:
                    return True
                if j + nums[j] > max_step:
                    max_step = j + nums[j]
                    next_step = j
            i = next_step


if __name__ == '__main__':
    s = Solution()
    s.canJump([2, 0])
